import request from '@/utils/request'
import type { BaseResponse, PaginationResponse } from '@/types/common/response'
import type {
  OperationLogListItem,
  OperationLogDetail,
  OperationLogListRequest,
  BatchDeleteOperationLogsRequest
} from '@/types/api/operationLog'

/**
 * 操作日志管理相关API
 */
export const operationLogApi = {
  /**
   * 获取操作日志列表
   * @param params 查询参数
   */
  getLogList(params: OperationLogListRequest) {
    return request.get<BaseResponse<PaginationResponse<OperationLogListItem>>>('/operation-logs', { params })
  },

  /**
   * 获取操作日志详情
   * @param id 日志ID
   */
  getLogDetail(id: number) {
    return request.get<BaseResponse<OperationLogDetail>>(`/operation-logs/${id}`)
  },

  /**
   * 删除操作日志
   * @param id 日志ID
   */
  deleteLog(id: number) {
    return request.delete<BaseResponse<null>>(`/operation-logs/${id}`)
  },

  /**
   * 批量删除操作日志
   * @param ids 日志ID列表
   */
  batchDeleteLogs(ids: number[]) {
    return request.post<BaseResponse<null>>('/operation-logs/batch-delete', ids)
  }
}
